<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/resources/jstl_contexpath.jsp"%>
<!DOCTYPE html>
<html>
<head>
    <title>虎丘婚纱城管理系统</title>
    <link rel="stylesheet" type="text/css" href="<c:url value="/resources/bs3/css/bootstrap.min.css" />" />
    <link rel="stylesheet" type="text/css" href="<c:url value="/resources/css/bootstrap-reset.css" />" />
    <link rel="stylesheet" type="text/css" href="<c:url value="/resources/font-awesome/css/font-awesome.css" />" />
    <link rel="stylesheet" type="text/css" href="<c:url value="/resources/css/clndr.css" />" />
    <link rel="stylesheet" type="text/css" href="<c:url value="/resources/css/style.css" />" />
    <link rel="stylesheet" type="text/css" href="<c:url value="/resources/css/style-responsive.css" />" />

    <!-- start: CSS -->
    <link rel="stylesheet" type="text/css" href="<c:url value="/resources/assets/css/bootstrap.min.css" />" />
    <link rel="stylesheet" type="text/css" href="<c:url value="/resources/assets/css/style.min.css" />" />
    <link rel="stylesheet" type="text/css" href="<c:url value="/resources/assets/css/retina.min.css" />" />
    <!-- end: CSS -->

    <!-- start: Favicon and Touch Icons -->
    <link rel="apple-touch-icon-precomposed" sizes="144x144" href="<c:url value="/resources/assets/ico/apple-touch-icon-144-precomposed.png" />" />
    <link rel="apple-touch-icon-precomposed" sizes="114x114" href="<c:url value="/resources/assets/ico/apple-touch-icon-114-precomposed.png" />" />
    <link rel="apple-touch-icon-precomposed" sizes="72x72" href="<c:url value="/resources/assets/ico/apple-touch-icon-72-precomposed.png" />" />
    <link rel="apple-touch-icon-precomposed" sizes="57x57" href="<c:url value="/resources/assets/ico/apple-touch-icon-57-precomposed.png" />" />
    <link rel="shortcut icon" href="<c:url value="/resources/assets/ico/favicon.png" />" />
    <!-- end: Favicon and Touch Icons -->

</head>
<body>

<!-- start: Header -->
<%@ include file="/resources/head.jsp" %>
<!-- end: Header -->

<div class="container">
    <div class="row">
        <!-- start: Main Menu -->
        <%@ include file="/resources/sidebar.jsp" %>
        <!-- end: Main Menu -->

        <!-- start: Content -->
        <div id="content" class="col-lg-10 col-sm-11">
            <div class="row">
                <div class="col-lg-12">
                    <div class="box">
                        <div class="box-header">
                            <h2><i class="fa fa-align-justify"></i><span class="break"></span>编辑渠道</h2>
                            <div class="box-icon">
                            </div>
                        </div>
                        <div class="box-content">
                            <input type="hidden" id="channel_id" name="channel_id" value="${channel_info.id}" />
                            <form class="form-horizontal">
                                <div class="form-group has-success">
                                    <label class="control-label" >渠道名称</label>
                                    <input type="text" class="form-control" id="channel_name" name="channel_name" value="${channel_info.name}" />
                                    <label class="control-label" >渠道类型</label>
                                    <div class="controls">
                                        <select id="channel_type" name="channel_type" class="form-control">
                                            <c:if test="${channel_info.channel_type == 0}">
                                                <option value="0" selected>线下</option>
                                                <option value="1" >线上</option>
                                            </c:if>
                                            <c:if test="${channel_info.channel_type == 1}">
                                                <option value="0" >线下</option>
                                                <option value="1" selected>线上</option>
                                            </c:if>
                                        </select>
                                    </div>
                                    <label class="control-label" >网址</label>
                                    <input type="text" class="form-control" id="website_url" name="website_url" value="${channel_info.website_url}" readonly/>
                                    <label class="control-label" >推广位置</label>
                                    <input type="text" class="form-control" id="spread_position" name="spread_position" value="${channel_info.spread_position}" />
                                    <label class="control-label" >推广周期</label>
                                    <input type="text" class="form-control" id="spread_cycle" name="spread_cycle" value="${channel_info.spread_cycle}" />

                                    <label class="control-label">推广内容</label>
                                    <div class="controls">
                                        <textarea id="spread_content" name="spread_content" rows="7" style="width: 100%">${channel_info.spread_content}</textarea>
                                    </div>

                                    <label class="control-label" >推广成本</label>
                                    <input type="text" class="form-control" id="spread_cost" name="spread_cost" value="${channel_info.spread_cost}" />
                                </div>
                                <div class="form-actions">
                                    <button type="button" class="btn btn-primary" id="save">保存</button>
                                    <button type="button" class="btn" id="cancel">取消</button>
                                </div>

                            </form>
                        </div>
                    </div>
                </div><!--/col-->
            </div>
        </div>
    </div>
</div>
<%@ include file="/resources/managerfoot.jsp"%>

<!-- start: JavaScript-->
<script type="text/javascript" src="<c:url value="/resources/assets/js/jquery-2.1.0.min.js" />" ></script>
<script type="text/javascript" src="<c:url value="/resources/assets/js/jquery-migrate-1.2.1.min.js" />" ></script>
<script type="text/javascript" src="<c:url value="/resources/assets/js/bootstrap.min.js" />" ></script>

<!-- page scripts -->
<script type="text/javascript" src="<c:url value="/resources/assets/js/jquery-ui-1.10.3.custom.min.js" />" ></script>
<script type="text/javascript" src="<c:url value="/resources/assets/js/jquery.sparkline.min.js" />" ></script>
<script type="text/javascript" src="<c:url value="/resources/assets/js/jquery.dataTables.min.js" />" ></script>
<script type="text/javascript" src="<c:url value="/resources/assets/js/dataTables.bootstrap.min.js" />" ></script>

<!-- theme scripts -->
<script type="text/javascript" src="<c:url value="/resources/assets/js/custom.min.js" />" ></script>
<script type="text/javascript" src="<c:url value="/resources/assets/js/core.min.js" />" ></script>

<!-- inline scripts related to this page -->
<script type="text/javascript" src="<c:url value="/resources/assets/js/pages/table.js" />" ></script>

<!-- end: JavaScript-->

<script>
    $(function () {
        $('#cancel').click(function(){
            window.location.href="${ctx}/manage/channel/index";
        });
        $('#save').click(function(){
            var channel_id = $.trim($('#channel_id').val());
            var channel_name = $.trim($('#channel_name').val());
            if(channel_name == '') {
                alert("请输入渠道名称");
                return false;
            }

            var channel_type = $('#channel_type option:selected').val();
            var website_url = $.trim($('#website_url').val());
            var spread_position = $.trim($('#spread_position').val());
            var spread_cycle = $.trim($('#spread_cycle').val());
            var spread_content = $.trim($('#spread_content').val());
            var spread_cost = $.trim($('#spread_cost').val());

            $.ajax({
                url:"${ctx}/manage/channel/doedit",
                type: "post",
                data:{channel_id:channel_id,channel_name:channel_name,channel_type:channel_type,website_url:website_url,spread_position:spread_position,spread_cycle:spread_cycle,spread_content:spread_content,spread_cost:spread_cost},
                success:function(data){
                    if(data == 1){
                        alert("成功");
                        window.location.href="${ctx}/manage/channel/index";
                    } else {
                        alert("失败");
                    }
                }
            })
        })
    });
</script>
</body>
</html>